//
//  ViewController.m
//  水平滚动添加button
//
//  Created by 石虎 on 2017/10/18.
//  Copyright © 2017年 石虎. All rights reserved.
//

#import "ViewController.h"
#import "OKTScrollAddView.h"

@interface ViewController ()
@property (nonatomic ,strong) OKTScrollAddView *scrollView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.scrollView = [[OKTScrollAddView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 200)];
    
    [_scrollView.addItemButton setBackgroundImage:[UIImage imageNamed:@"pd_pic_add"] forState:UIControlStateNormal];
    [_scrollView.addItemButton addTarget:self action:@selector(clickToAddPic:) forControlEvents:UIControlEventTouchUpInside];
    
    
    _scrollView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:_scrollView];
    
}

- (void)clickToAddPic:(UIButton *)sender {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _scrollView.itemSize.width, _scrollView.itemSize.height)];
    label.backgroundColor = [UIColor lightGrayColor];
    label.text = [NSString stringWithFormat:@"%lu",(unsigned long)_scrollView.itemCount];
    label.font = [UIFont systemFontOfSize:100];
    label.textAlignment = NSTextAlignmentCenter;
    label.adjustsFontSizeToFitWidth = YES;
    [_scrollView addItem:label];
}


@end
